/**
 * Created by JF-Z on 2017/12/7.
 */
angular.module('service.fileupload', ['ngResource'])

    .service('FileUpload', ['$q', '$resource', '$http', function ($q, $resource, $http) {

        this.uploadFileToUrl = function (file) {
            var fd = new FormData();
            fd.append("bizcode","merchreg");
            fd.append("file",file);
            var deferred = $q.defer();
            $http({
                method: "POST",
                url: uploadUrl,
                data: fd,
                headers: {'Content-Type': undefined},
                transformRequest: angular.identity
            }).then(function (data, status, headers, config) {
                deferred.resolve(data);
            }, function (error, status, headers, config) {
                deferred.reject(error);
            });
            return deferred.promise;
        };
    }]);
